import { useConfigContext } from "@lib/config/context";

export const logger = {
  warn: (...args: any[]) => {
    if (endabledLogging()) {
      console.warn(...args);
    }
  },
  log: (...args: any[]) => {
    if (endabledLogging()) {
      console.log(...args);
    }
  },
  error: (...args: any[]) => {
    if (endabledLogging()) {
      console.error(...args);
    }
  },
};

const endabledLogging = () => {
  const context = useConfigContext();
  return context.logging === true;
};
